import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
import operate from '@dfeidao/atom-nodejs/db/operate';
import { systemid,productid} from '../../atom/config';

interface Message {
filter:{
	productid:string,
	work_bill_no:string,
	visit_people:string,
	score:string,
	visit_phone:string,
	revisit_days:string,
	visit_result:string,
	record_no:string,
	cust_sat:string
},
filter1:{
	productid:string,
	work_order_status:string
}
}
// 表名	cust_reask_rec				
// 标题	客户回访记录				
// 字段名称	字段标题	字段类型	字段长度	是否为空	是否主键
// visit_people	回访人	string	50	√	ⅹ
// score	分值	string	50	√	ⅹ
// productid	产品ID	string	50	√	ⅹ
// visit_phone	回访人电话	string	50	√	ⅹ
// revisit_days	回访时间	timestamp	50	√	ⅹ
// work_bill_no	工单编号	string	50	√	ⅹ
// visit_result	回访结果	string	50	√	ⅹ
// record_no	记录编号	string	50	√	ⅹ
// cust_sat	客户满意度	int	50	ⅹ	ⅹ
// _id	id	string	50	ⅹ	√
export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders){
const { exec, insert, update, del } = operate(action_id,session_id,systemid);
// 修改数据
update('cust_reask_rec', { productid,work_bill_no:message.filter.work_bill_no},{productid:message.filter.productid,work_bill_no:message.filter.work_bill_no,
visit_people:message.filter.visit_people,score:message.filter.score,cust_sat:message.filter.cust_sat,record_no:message.filter.record_no,visit_phone:message.filter.visit_phone,
visit_result:message.filter.visit_result,revisit_days:message.filter.revisit_days});

update('work_order', { productid,work_bill_no:message.filter.work_bill_no},{work_order_status:message.filter1.work_order_status});
const ret = await exec();
return ret;
}
